#include "device_discover.h"

#include <string.h>
#define NULL 0

device_discover::device_discover(void)
{
}

device_discover::~device_discover(void)
{
}

int device_discover::discover_devices( char * parameter, char  device_pathes[32][256] )
{
	return -1;
}

int device_discover::enum_and_create_devices( char * parameter )
{
	return -1;
}

device_base * device_discover::get_device( int index )
{
	return 0;
}

int device_discover::get_device_number()
{
	return -1;
}

int device_discover::update_devices( int * removed_num, int * new_num , char * parameter)
{
	return 0;
}

device_base * device_discover::get_first_device( MK_POSITION & pos )
{
	return 0;
}

device_base * device_discover::get_next_device( MK_POSITION & pos )
{
	return 0;
}

device_base * device_discover::get_device_by_position( MK_POSITION pos )
{
	return 0;
}


int device_discover::destroy_removed_deviced()
{
	return 0;
}

device_base * device_discover::add_new_device(char * dev_path, MK_HANDLE devHandle)
{
	return 0;
}

int device_discover::delete_device( MK_POSITION pos )
{
	return 0;
}

int device_discover::split_enum_strings( char * input, char scsi_enum_id[256], char scsi_waitfor_id[256], char hid_enum[1024] )
{
	char * delim = ",";
	char temp[1024] = {0};
	char * p = NULL;
	strncpy(temp, input, 1024);

	p = strtok(temp, delim);
	if(!p) return 1;

	strncpy(scsi_enum_id, p, 256);

	p = strtok(NULL, delim);
	if(!p) return 2;

	strncpy(scsi_waitfor_id, p, 256);

	p = strtok(NULL, delim);
	if(!p) return 0;

	strncpy(hid_enum, p, 1024);

	ltrim(scsi_enum_id);
	ltrim(scsi_waitfor_id);
	ltrim(hid_enum);

	return 0;
}

int device_discover::split_hid_strings( char * input, char hidEnum[16][256])
{
	char * delim = "|";
	char temp[1024] = {0};
	char * p = NULL;
	int  num = 0;
	strncpy(temp, input, 1024);

	p = strtok(temp, delim);
	if(!p) return 1;

	strncpy(hidEnum[num++], p, 256);

	while(p = strtok(NULL, delim))
	{
		strncpy(hidEnum[num++], p, 256);
	}

	return 0;
}



void device_discover::ltrim ( char *s )
{
	char *p;
	p = s;
	while ( *p == ' ' || *p == '\t' ) {*p++;}
	strcpy ( s,p );
}
